#include<stdio.h>

int choose7(int N)
{
    int count=0;
    for(int i=1;i<=N;i++)
    {
        int n=i;
        int flag = 1;
        while(n)
        {
            if(flag == 1 && n%7 == 0)
            {
                count++;
                break;
            }
            if(n%10==7)
            {
                count++;
                break;
            }
            else
            {
            	n/=10;
                flag = 0;
            }
        }
    }
    return count;
}
int main()
{
    int num;
    scanf("%d",&num);
    printf("%d",choose7(num));
    
}